﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_GetNotBangdingRole]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_GetNotBangdingRole];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_GetNotBangdingRole]
    @FlowID int,
    @StepID int
AS
BEGIN
SET NOCOUNT ON;

SELECT
		role_id,
		role_name 
    FROM
		dbo.uds_role 
    WHERE role_id not in
		(
			SELECT b.role_id
			FROM
				dbo.uds_flow_member_bind a ,
				dbo.uds_role b 
			WHERE
				a.obj_id = b.role_id 
				and a.flow_id = @flowid
				and a.step_id = @stepid
				and a.obj_type =3 /* role */
		);

END
GO